//
//  FQIViewExtension.swift
//  YQInformation
//
//  Created by Max on 2017/11/3.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

extension UIView {
    
    func addBoarder(color : UIColor , width : CGFloat = 1){
        self.layer.borderColor = color.cgColor
        self.layer.borderWidth = width
    }
    
    
    func addCorner(radius : CGFloat = 5) {
        self.layer.cornerRadius = radius
        self.layer.masksToBounds = true
    }
    
}

extension String {
    
    public var double : Double {
        return Double(self) ?? 0
    }
    
    public var int : Int {
        return Int(self) ?? 0
    }
    
    public var float : Float {
        return Float(self) ?? 0
    }
}

extension Double {
    /// 保留小数的字符串
    ///
    /// - Parameter numberOfDecimals: 小数位
    /// - Returns: 返回字符串
    func decimalString(_ numberOfDecimals : uint) -> String {
        return String(format: "%.\(numberOfDecimals)f", self)
    }
}
